home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / pico / estruct.h < prev    next >
C/C++ Source or Header  |  1996-07-09  |  13KB  |  315 lines

  1. /*
  2.  * $Id: estruct.h,v 4.30 1996/07/09 23:08:13 mikes Exp $
  3.  *
  4.  * Program:    Struct and preprocessor definitions
  5.  *
  6.  *
  7.  * Michael Seibel
  8.  * Networks and Distributed Computing
  9.  * Computing and Communications
  10.  * University of Washington
  11.  * Administration Builiding, AG-44
  12.  * Seattle, Washington, 98195, USA
  13.  * Internet: mikes@cac.washington.edu
  14.  *
  15.  * Please address all bugs and comments to "pine-bugs@cac.washington.edu"
  16.  *
  17.  *
  18.  * Pine and Pico are registered trademarks of the University of Washington.
  19.  * No commercial use of these trademarks may be made without prior written
  20.  * permission of the University of Washington.
  21.  * 
  22.  * Pine, Pico, and Pilot software and its included text are Copyright
  23.  * 1989-1996 by the University of Washington.
  24.  * 
  25.  * The full text of our legal notices is contained in the file called
  26.  * CPYRIGHT, included with this distribution.
  27.  *
  28.  */
  29. /*    ESTRUCT:    Structure and preprocesser defined for
  30.             MicroEMACS 3.6
  31.  
  32.             written by Dave G. Conroy
  33.             modified by Steve Wilhite, George Jones
  34.             greatly modified by Daniel Lawrence
  35. */
  36.  
  37. #ifndef    ESTRUCT_H
  38. #define    ESTRUCT_H
  39.  
  40. /*    Configuration options    */
  41.  
  42. #define CVMVAS  1    /* arguments to page forward/back in pages    */
  43. #define    NFWORD    1    /* forward word jumps to begining of word    */
  44. #define    TYPEAH    0    /* type ahead causes update to be skipped    */
  45. #define    REVSTA    1    /* Status line appears in reverse video        */
  46.  
  47.  
  48. /*    internal constants    */
  49.  
  50. #define    NBINDS    50            /* max # of bound keys        */
  51. #define NFILEN  80                      /* # of bytes, file name        */
  52. #define NBUFN   16                      /* # of bytes, buffer name      */
  53. #define NLINE   256                     /* # of bytes, line             */
  54. #define    NSTRING    256            /* # of bytes, string buffers    */
  55. #define NPAT    80                      /* # of bytes, pattern          */
  56. #undef    HUGE
  57. #define HUGE    1000                    /* Huge number                  */
  58. #define    NLOCKS    100            /* max # of file locks active    */
  59.  
  60. #define AGRAVE  0x60                    /* M- prefix,   Grave (LK201)   */
  61. #define METACH  0x1B                    /* M- prefix,   Control-[, ESC  */
  62. #define CTMECH  0x1C                    /* C-M- prefix, Control-\       */
  63. #define EXITCH  0x1D                    /* Exit level,  Control-]       */
  64. #define CTRLCH  0x1E                    /* C- prefix,   Control-^       */
  65. #define HELPCH  0x1F                    /* Help key,    Control-_       */
  66.  
  67. #undef  CTRL
  68. #define CTRL    0x0100                  /* Control flag, or'ed in       */
  69. #define META    0x0200                  /* Meta flag, or'ed in          */
  70. #define CTLX    0x0400                  /* ^X flag, or'ed in            */
  71. #define    SPEC    0x0800            /* special key (arrow's, etc)    */
  72. #define    FUNC    0x1000            /* special key (function keys)    */
  73. #if    defined(DOS) || defined(OS2)
  74. #define    MENU    0x2000            /* Menu command            */
  75. #define    ALTD    0x4000            /* ALT key...            */
  76. #endif
  77.  
  78. #define    QNORML    0x0000            /* Flag meaning no flag ;)    */
  79. #define    QFFILE    0x0001            /* Flag buffer for file neme    */
  80. #define    QDEFLT    0x0002            /* Flag to use default answer    */
  81. #define    QBOBUF    0x0004            /* Start with cursor at BOL    */
  82.  
  83. #undef    FALSE
  84. #define FALSE   0                       /* False, no, bad, etc.         */
  85. #undef    TRUE
  86. #define TRUE    1                       /* True, yes, good, etc.        */
  87. #define ABORT   2                       /* Death, ^G, abort, etc.       */
  88.  
  89. #define FIOSUC  0                       /* File I/O, success.           */
  90. #define FIOFNF  1                       /* File I/O, file not found.    */
  91. #define FIOEOF  2                       /* File I/O, end of file.       */
  92. #define FIOERR  3                       /* File I/O, error.             */
  93. #define    FIOLNG    4            /*line longer than allowed len    */
  94. #define    FIODIR    5            /* File is a directory        */
  95. #define    FIONWT    6            /* File lacks write permission    */
  96. #define    FIONRD    7            /* File lacks read permission    */
  97. #define    FIONEX    8            /* File lacks exec permission    */
  98. #define    FIOSYM    9            /* File is a symbolic link    */
  99. #define    FIOPER    10            /* Generic permission denied    */
  100.  
  101.  
  102. #define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
  103. #define CFKILL  0x0002                  /* Last command was a kill      */
  104. #define CFFILL  0x0004                  /* Last command was a kill      */
  105.  
  106. #define    BELL    0x07            /* the BELL character        */
  107. #define    TAB    0x09            /* the TAB character        */
  108. #define    DEL    0x7f            /* the DELETE character        */
  109.  
  110.  
  111. /*
  112.  * macros to help filter character input
  113.  */
  114. #define    LOBIT_CHAR(C)    ((C) > 0x1f && (C) < 0x7f)
  115. #define    HIBIT_CHAR(C)    ((C) > 0x7f && (C) <= 0xff)
  116. #define    HIBIT_OK(C)    (!(gmode & MDHBTIGN))
  117. #define    VALID_KEY(C)    (LOBIT_CHAR(C) || (HIBIT_OK(C) && HIBIT_CHAR(C)))
  118.  
  119.  
  120. /*
  121.  * Definitions for varisous port-specific keymenu data
  122.  */
  123. #ifndef    KS_OSDATAVAR
  124. #define    KS_OSDATAVAR
  125. #define    KS_OSDATAGET(X)
  126. #define    KS_OSDATASET(X, Y)
  127.  
  128. #define    KS_NONE
  129. #define    KS_SCREENHELP
  130. #define    KS_PREVPAGE
  131. #define    KS_NEXTPAGE
  132. #define    KS_SEND
  133. #define    KS_RICHHDR
  134. #define    KS_CURPOSITION
  135. #define    KS_POSTPONE
  136. #define    KS_CANCEL
  137. #define    KS_ATTACH
  138. #define    KS_SAVEFILE
  139. #define    KS_READFILE
  140. #define    KS_EXIT
  141. #define    KS_JUSTIFY
  142. #define    KS_WHEREIS
  143. #define    KS_SEND
  144. #define    KS_ALTEDITOR
  145. #define    KS_SPELLCHK
  146. #endif
  147.  
  148.  
  149. /*
  150.  * There is a window structure allocated for every active display window. The
  151.  * windows are kept in a big list, in top to bottom screen order, with the
  152.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  153.  * The flag field contains some bits that are set by commands to guide
  154.  * redisplay; although this is a bit of a compromise in terms of decoupling,
  155.  * the full blown redisplay is just too expensive to run for every input
  156.  * character.
  157.  */
  158. typedef struct  WINDOW {
  159.         struct  WINDOW *w_wndp;         /* Next window                  */
  160.         struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
  161.         struct  LINE *w_linep;          /* Top line in the window       */
  162.         struct  LINE *w_dotp;           /* Line containing "."          */
  163.         short   w_doto;                 /* Byte offset for "."          */
  164.         struct  LINE *w_markp;          /* Line containing "mark"       */
  165.         short   w_marko;                /* Byte offset for "mark"       */
  166.         struct  LINE *w_imarkp;         /* INTERNAL Line with "mark"    */
  167.         short   w_imarko;               /* INTERNAL "mark" byte offset  */
  168.         char    w_toprow;               /* Origin 0 top row of window   */
  169.         char    w_ntrows;               /* # of rows of text in window  */
  170.         char    w_force;                /* If NZ, forcing row.          */
  171.         char    w_flag;                 /* Flags.                       */
  172. }       WINDOW;
  173.  
  174. #define WFFORCE 0x01                    /* Window needs forced reframe  */
  175. #define WFMOVE  0x02                    /* Movement from line to line   */
  176. #define WFEDIT  0x04                    /* Editing within a line        */
  177. #define WFHARD  0x08                    /* Better to a full display     */
  178. #define WFMODE  0x10                    /* Update mode line.            */
  179.  
  180. /*
  181.  * Text is kept in buffers. A buffer header, described below, exists for every
  182.  * buffer in the system. The buffers are kept in a big list, so that commands
  183.  * that search for a buffer by name can find the buffer header. There is a
  184.  * safe store for the dot and mark in the header, but this is only valid if
  185.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  186.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  187.  * the header line in "b_linep".
  188.  *     Buffers may be "Inactive" which means the files accosiated with them
  189.  * have not been read in yet. These get read in at "use buffer" time.
  190.  */
  191. typedef struct  BUFFER {
  192.     struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
  193.     struct  LINE *b_dotp;           /* Link to "." LINE structure   */
  194.     short   b_doto;                 /* Offset of "." in above LINE  */
  195.     struct  LINE *b_markp;          /* The same as the above two,   */
  196.     short   b_marko;                /* but for the "mark"           */
  197.     struct  LINE *b_linep;          /* Link to the header LINE      */
  198.     long    b_linecnt;        /* Lines in buffer (mswin only)    */
  199.     long    b_mode;            /* editor mode of this buffer    */
  200.     char    b_active;        /* window activated flag    */
  201.     char    b_nwnd;                 /* Count of windows on buffer   */
  202.     char    b_flag;                 /* Flags                        */
  203.     char    b_fname[NFILEN];        /* File name                    */
  204.     char    b_bname[NBUFN];         /* Buffer name                  */
  205. }    BUFFER;
  206.  
  207. #define BFTEMP     0x01                    /* Internal temporary buffer     */
  208. #define BFCHG      0x02                    /* Changed since last write      */
  209. #define BFWRAPOPEN 0x04                    /* Wordwrap should open new line */
  210.  
  211.  
  212. /*
  213.  * The starting position of a region, and the size of the region in
  214.  * characters, is kept in a region structure.  Used by the region commands.
  215.  */
  216. typedef struct  {
  217.         struct  LINE *r_linep;          /* Origin LINE address.         */
  218.         short   r_offset;               /* Origin LINE offset.          */
  219.         long    r_size;                 /* Length in characters.        */
  220. }       REGION;
  221.  
  222.  
  223. /*
  224.  * character and attribute pair.  The basic building block
  225.  * of the editor.  The bitfields may have to be changed to a char
  226.  * and short if there are problems...
  227.  */
  228. typedef    struct CELL {
  229.     unsigned int c : 8;        /* Character value in cell      */
  230.     unsigned int a : 8;        /* Its attributes               */
  231. } CELL;
  232.  
  233.  
  234. /*
  235.  * All text is kept in circularly linked lists of "LINE" structures. These
  236.  * begin at the header line (which is the blank line beyond the end of the
  237.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  238.  * number of bytes in the line (the "used" size), the size of the text array,
  239.  * and the text. The end of line is not stored as a byte; it's implied. Future
  240.  * additions will include update hints, and a list of marks into the line.
  241.  */
  242. typedef struct  LINE {
  243.         struct  LINE *l_fp;             /* Link to the next line        */
  244.         struct  LINE *l_bp;             /* Link to the previous line    */
  245.         short   l_size;                 /* Allocated size               */
  246.         short   l_used;                 /* Used size                    */
  247.         CELL    l_text[1];              /* A bunch of characters.       */
  248. }       LINE;
  249.  
  250. #define lforw(lp)       ((lp)->l_fp)
  251. #define lback(lp)       ((lp)->l_bp)
  252. #define lgetc(lp, n)    ((lp)->l_text[(n)])
  253. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  254. #define llength(lp)     ((lp)->l_used)
  255.  
  256. /*
  257.  * The editor communicates with the display using a high level interface. A
  258.  * "TERM" structure holds useful variables, and indirect pointers to routines
  259.  * that do useful operations. The low level get and put routines are here too.
  260.  * This lets a terminal, in addition to having non standard commands, have
  261.  * funny get and put character code too. The calls might get changed to
  262.  * "termp->t_field" style in the future, to make it possible to run more than
  263.  * one terminal type.
  264.  */
  265. typedef struct  {
  266.         short   t_nrow;                 /* Number of rows - 1.          */
  267.         short   t_ncol;                 /* Number of columns.           */
  268.     short    t_margin;        /* min margin for extended lines*/
  269.     short    t_scrsiz;        /* size of scroll region "    */
  270.         short   t_mrow;                 /* Number of rows in menu       */
  271.         int     (*t_open)();            /* Open terminal at the start.  */
  272.         int     (*t_close)();           /* Close terminal at end.       */
  273.         int     (*t_getchar)();         /* Get character from keyboard. */
  274.         int     (*t_putchar)();         /* Put character to display.    */
  275.         int     (*t_flush)();           /* Flush output buffers.        */
  276.         int     (*t_move)();            /* Move the cursor, origin 0.   */
  277.         int     (*t_eeol)();            /* Erase to end of line.        */
  278.         int     (*t_eeop)();            /* Erase to end of page.        */
  279.         int     (*t_beep)();            /* Beep.                        */
  280.     int    (*t_rev)();        /* set reverse video state    */
  281. }       TERM;
  282.  
  283. /*    structure for the table of initial key bindings        */
  284.  
  285. typedef struct  {
  286.         short   k_code;                 /* Key code                     */
  287.         int     (*k_fp)();              /* Routine to handle it         */
  288. }       KEYTAB;
  289.  
  290. /*      sturcture used for key menu painting         */
  291.  
  292. typedef struct {
  293.     char    *name;            /* key to display          */
  294.     char    *label;            /* function name key envokes    */
  295.     KS_OSDATAVAR            /* port-specific data */
  296. }    KEYMENU;
  297.  
  298. typedef struct {
  299.     char    *name;            /* key to display          */
  300.     char    *label;            /* function name key envokes    */
  301.     int    key;            /* what to watch for and return    */
  302.     KS_OSDATAVAR            /* port-specific data */
  303. }    EXTRAKEYS;
  304.  
  305. #ifdef    MOUSE
  306.  
  307. /* Test if mouse position (R, C) is in menu item (X) */
  308. #define    M_ACTIVE(R, C, X)    (((unsigned)(R)) >= (X)->tl.r       \
  309.                     && ((unsigned)(R)) <= (X)->br.r \
  310.                     && ((unsigned)(C)) >= (X)->tl.c \
  311.                     && ((unsigned)(C)) < (X)->br.c)
  312. #endif    /* MOUSE */
  313.  
  314. #endif    /* ESTRUCT_H */
  315.